<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org" >
<head>
    <!--公用头部-->
    <th:block th:replace="common/head::commonHead('定时任务日志-小邑')" />
    <style>
    </style>
</head>
<!--公用js-->
<th:block th:replace="common/head::commonJs"/>
<body marginwidth="0" marginheight="0">
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form" id="scheduleLogForm">
                <div class="layui-form">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">任务名称</label>
                            <div class="layui-input-inline">
                                <input id="jobName" name="jobName" class="layui-input" autocomplete="off"
                                       type="text" placeholder="请输入任务名称"/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="button" id="searchBtn"
                                    class="xy-btn xy-btn-primary icon-btn xy-btn-sm">
                                <i class="layui-icon">&#xe615;</i> 搜索
                            </button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="layui-card">
        <div class="layui-card-body">
            <table class="layui-hide" id="logTable" lay-filter="logTable"></table>
            <script id="logBar" type="text/html">
                {{#if (d.status == 0) { }}
                <span style="color: green">成功</span>
                {{# }else if(d.status == 1){ }}
                <span style="color: red">异常</span>
                {{# } }}
            </script>
            <script id="logCreateTime" type="text/html">
                {{layui.util.toDateString(d.createTime,  "yyyy-MM-dd HH:mm:ss")}}
            </script>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['table', 'form', 'jquery'], function () {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        var scheduleLogTable =  table.render({
            elem: '#logTable'
            ,method:'post'
            ,url: basePath + '/scheduleLog/list' //数据接口
            ,page: true //开启分页
            ,toolbar: false
            ,cellMinWidth: 100
            ,cols: [ [ //表头
                {title: '名称', field: 'jobName', align: 'center'},
                {title: '运行类', field: 'beanName', align: 'center'},
                {title: '参数集合', field: 'params', align: 'center'},
                {title: '运行时间', field: 'createTime', templet: '#logCreateTime', align: 'center'},
                {title: '运行时长 / 毫秒', field: 'times', align: 'center'},
                {title: '状态', toolbar: '#log-bar', align: 'center', width: 150}
            ] ]
            ,limit: 10
            ,limits: [10, 20, 50, 100]
            ,page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: [  'prev', 'page', 'next', 'skip','count','limit'] //自定义分页布局
                , curr: 1 //设定初始在第 5 页
                , groups: 5 //只显示 1 个连续页码
                , first: false //不显示首页
                , last: false //不显示尾页
                , theme:"#1E9FFF"
            }
        });

        // 搜索
        $('#searchBtn').on('click',function () {
            scheduleLogTable.reload({
                where: getFormData('scheduleLogForm')
            });
        });
        window.error = function (obj) {
            layer.open({
                type: 1,
                title: '异常信息',
                shade: 0,
                area: ['450px', '350px'],
                content: '<div class="layui-fluid">' +
                    '<div class="layui-card">' +
                     '<div class="layui-card-body">' + obj.data['error'] + '</div>' +
                    '</div>' +
                    '</div>'
            });
        }
    })
</script>
</html>